$('#folderSelect').on('change', e => {
  let files = Array.from(event.target.files)
  let folderName = files[0].webkitRelativePath.split('/')[0]
  $('#folderShow').text(folderName)
  $('#imgCont').html('')
  let fileps = files.map(file => {
    let reader = new FileReader()
    let img = document.createElement('img')
    return new Promise(resolve => {
      reader.addEventListener("load", function () {
        img.src = reader.result
        resolve(img)
      }, false)
      reader.readAsDataURL(file)
    })
  })
  Promise.all(fileps).then(l => 
    l.forEach(el => $('#imgCont').append(el))
  )
})

let w = localStorage.width
if(!w) w = 80
$('#widthShow').text(w)
$('#widthSelect').val(w)
$('#imgCont').width(w + '%')

$('#widthSelect').on('input', function(){
  let w = this.value
  $('#widthShow').text(w)
  localStorage.width = w
  $('#imgCont').width(w + '%')
})

